//
//  yxpGCDNotification.m
//  TestProject
//
//  Created by 杨小平 on 14-8-27.
//  Copyright (c) 2014年 yangxiaoping. All rights reserved.
//

#import "yxpGCDNotification.h"
#import "GCDiscreetNotificationView.h"

@interface yxpGCDNotification ()
{
    GCDiscreetNotificationView *_notificationView;
}

@end

@implementation yxpGCDNotification

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIButton *button1=[[UIButton alloc] initWithFrame:CGRectMake(10, 74, 145, 40)];
    button1.tag=11;
    [button1 setTitle:@"上边弹出" forState:UIControlStateNormal];
    [button1 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button1 setBackgroundColor:[UIColor skyBlueColor]];
    [button1 addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button1];
    
    UIButton *button2=[[UIButton alloc] initWithFrame:CGRectMake(165, 74, 145, 40)];
    button2.tag=22;
    [button2 setTitle:@"下边弹出" forState:UIControlStateNormal];
    [button2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [button2 setBackgroundColor:[UIColor skyBlueColor]];
    [button2 addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button2];

}
- (void)buttonClick:(UIButton *)button
{
    if (button.tag==11) {
        GCDiscreetNotificationView *notificationView = [[GCDiscreetNotificationView alloc] initWithText:@"NotificationView" showActivity:YES inPresentationMode:GCDiscreetNotificationViewPresentationModeTop inView:self.view];
        [notificationView setBackViewColor:[UIColor redColor]];
        [notificationView show:YES];
        [notificationView hideAnimatedAfter:2.6];
    }else
    {
        GCDiscreetNotificationView *notificationView = [[GCDiscreetNotificationView alloc] initWithText:@"NotificationView" showActivity:YES inPresentationMode:GCDiscreetNotificationViewPresentationModeBottom inView:self.view];
        [notificationView show:YES];
        [notificationView hideAnimatedAfter:2.6];
    }

}


- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [_notificationView show:NO];
    [_notificationView hideAnimatedAfter:2.6];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
